<!DOCTYPE html>
<html class="x-admin-sm" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">
<head>
    <meta charset="UTF-8">
    <title>配置管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

    <link rel="stylesheet" th:href="@{/css/font.css}"/>
    <link rel="stylesheet" th:href="@{/css/xadmin.css}"/>

    <script th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
    <script type="text/javascript" th:src="@{/js/xadmin.js}"></script>
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="x-nav">
    <span class="layui-breadcrumb">
    <a href="">首页</a>
    <a href="">采购管理</a>
    <a><cite>采购订单管理</cite></a>
    </span><a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新"><i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <table class="layui-table layui-form">
                        <thead>
                        <tr>
                            <th style="display: none;">ID</th>
                            <th>创建时间</th>
                            <th>审核时间</th>
                            <th>开始时间</th>
                            <th>结束时间</th>
                            <th>创建员</th>
                            <th>审核员</th>
                            <th>采购员</th>
                            <th>库管理员</th>
                            <th>审核状态</th>
                            <th>确认状态</th>
                            <th>入库状态</th>
                            <th>供应商</th>
                            <th>总金额</th>
                            <th>操作</th>
                        </thead>
                        <tbody>
                        <tr th:each="item,itemStat : ${pages.getRecords()}">
                            <td th:text="${item.id}" style="display: none;"></td>
                            <td th:text="${#dates.format(item.createTime,'yyyy-MM-dd HH:mm:ss')}"></td>
                            <td th:text="${#dates.format(item.checkTime,'yyyy-MM-dd HH:mm:ss')}"></td>
                            <td th:text="${#dates.format(item.startTime,'yyyy-MM-dd HH:mm:ss')}"></td>
                            <td th:text="${#dates.format(item.endTime,'yyyy-MM-dd HH:mm:ss')}"></td>
                            <td th:text="${sysUserService.getNameById(item.createUserId)}"></td>
                            <td th:text="${sysUserService.getNameById(item.checkUserId)}"></td>
                            <td th:text="${sysUserService.getNameById(item.confirmUserId)}"></td>
                            <td th:text="${sysUserService.getNameById(item.warehouseId)}"></td>
                            <td th:text="${item.checkState==1?'已审核':'未审核'}"></td>
                            <td th:text="${item.confirmState==1?'已确认':'未确认'}"></td>
                            <td th:text="${item.warehouseState==1?'已入库':'未入库'}"></td>
                            <td th:text="${producerService.getNameById(item.producerId)}"></td>
                            <td th:text="${item.price}"></td>
                            <td class="td-manage">
                                <button class="layui-btn layui-btn layui-btn-xs" th:data-name="${item.id}" onclick="changeSH(this.getAttribute('data-name'))" sec:authorize="hasRole('PROCUREMENT_CONFIRM_CONFIRM')"><i class="layui-icon">&#xe642;</i>确认</button>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
                <div class="layui-card-body ">
                    <div class="page">
                        <div th:if="${pages.pages<=7}">
                            <a class="prev" href="javascript:void(0)" th:onclick="'javascript:toPage('+${(pages.getCurrent()-1)<=0?1:(pages.getCurrent()-1)}+')'">上一页</a>
                            <a href="javascript:void(0)" th:each="beforeNo:${beforePages}" th:text="${beforeNo}" class="num" th:onclick="'javascript:toPage('+${beforeNo}+')'"></a>
                            <span class="current" th:text="${pages.getCurrent()}"></span>
                            <a href="javascript:void(0)" th:each="afterNo:${afterPages}" th:text="${afterNo}" class="num" th:onclick="'javascript:toPage('+${afterNo}+')'"></a>
                            <a href="javascript:void(0)" class="next" th:onclick="'javascript:toPage('+${(pages.getCurrent()+1)>=pages.getPages()?pages.getPages():(pages.getCurrent()+1)}+')'">下一页</a>
                        </div>
                        <div th:if="${pages.pages>7}">
                            <a class="prev" href="javascript:void(0)" th:onclick="'javascript:toPage('+${(pages.getCurrent()-1)<=0?1:(pages.getCurrent()-1)}+')'">上一页</a>
                            <a href="javascript:void(0)" th:each="beforeNo:${beforePages}" th:text="${beforeNo}" class="num" th:onclick="'javascript:toPage('+${beforeNo}+')'"></a>
                            <span th:if="${pages.getCurrent()>4}" >...</span>
                            <span class="current" th:text="${pages.getCurrent()}"></span>
                            <span th:if="${pages.getCurrent()<(pages.getPages()-3)}" >...</span>
                            <a href="javascript:void(0)" th:each="afterNo:${afterPages}" th:text="${afterNo}" class="num" th:onclick="'javascript:toPage('+${afterNo}+')'"></a>
                            <a href="javascript:void(0)" class="next" th:onclick="'javascript:toPage('+${(pages.getCurrent()+1)>=pages.getPages()?pages.getPages():(pages.getCurrent()+1)}+')'">下一页</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>

    layui.use(['laydate','form'], function(){
        var laydate = layui.laydate;
        var form = layui.form;

        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });
    });

    function changeSH(id) {
        $.post(`/procurement/confirm/confirm_state`,{id: id},function (data) {
            layer.msg('确认成功!', {icon: 1, time: 1000});
            location.reload();
        });
    }
</script>
<script>

    function toPage(num) {
        $("#current").val(num);
        $("#searchForm").submit();
    }


    function toPage(num) {
        $("#current").val(num);
        $("#searchForm").submit();
    }
</script>
</html>